package com.ermax.aircond.manage.web.bean;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import javax.faces.event.AjaxBehaviorEvent;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Component;

import com.ermax.aircond.common.parameter.Status;
import com.ermax.aircond.maintain.domain.Building;
import com.ermax.aircond.maintain.domain.Floor;
import com.ermax.aircond.maintain.domain.Machine;
import com.ermax.aircond.maintain.domain.Room;
import com.ermax.aircond.maintain.service.MaintainService;
import com.ermax.aircond.manage.domain.ScheduleTerm;
import com.ermax.aircond.manage.service.ScheduleControlService;
import com.ermax.aircond.resource.MessageBundle;
import com.ermax.aircond.util.web.bean.DataTableBean;

@Scope("view")
@Component
public class ScheduleManageBean extends DataTableBean implements java.io.Serializable {
	
	private static final long serialVersionUID = 1L;
	private static final Logger logger = LoggerFactory.getLogger(ScheduleManageBean.class);
	private static final String STATUS_INIT = "INIT";
	private static final String STATUS_SEARCH = "SEARCH";
	private static final String STATUS_SELECT = "SELECT";	
	

	@Resource(name = "maintainService")
	private MaintainService maintainService;
	@Resource(name = "scheduleControlService")
	private ScheduleControlService scheduleControlService;


	private long selectedBuildingId;
	private long selectedFloorId;
	private long selectedRoomId;
	private long selectedMachineId;
	private long selectedScheduleTermId;
	
	private long clickedMachineId;		
	private Map<Long,Boolean> clickedMachineIdMap = new TreeMap<Long, Boolean>();	
	private List<SelectItem> clickedMachineOptions = new ArrayList<SelectItem>();
	
	private Map<Long, Machine> machineCacheMap = new HashMap<Long, Machine>();
	private List<ScheduleTerm> scheduleTerms = new ArrayList<ScheduleTerm>();
	
	private ScheduleTerm editItem = new ScheduleTerm();
	
	
	private long deleteScheduleId;
	private Map<Long, Boolean> deleteScheduleIdMap = new TreeMap<Long, Boolean>();
	
	//Options
	private List<SelectItem> buildingOptions = new ArrayList<SelectItem>();
	private List<SelectItem> floorOptions = new ArrayList<SelectItem>();
	private List<SelectItem> roomOptions = new ArrayList<SelectItem>();
	private List<SelectItem> machineOptions = new ArrayList<SelectItem>();	
	private List<SelectItem> minimumTemperatureOptions = new ArrayList<SelectItem>();
	private List<SelectItem> temperatureOptions = new ArrayList<SelectItem>();
	private List<SelectItem> hourOptions = new ArrayList<SelectItem>();
	private List<SelectItem> minuteOptions = new ArrayList<SelectItem>();

	private String status = "";
	private String searchDescription = "";
	
	@PostConstruct
	public void init() {
		try {
			reset();
		} catch (Exception ex) {
			String message = MessageBundle.getInstance().getMessage("error_init_fail", FacesContext.getCurrentInstance().getViewRoot().getLocale());
			FacesMessage facesMessage = new FacesMessage(message);
			FacesContext.getCurrentInstance().addMessage(null, facesMessage);
		}
	}

	private void reset() throws Exception {
		status = STATUS_INIT;
		
		hourOptions = createHourOptions();
		minuteOptions = createMinuteOptions();
		buildingOptions = createBuildingOptions();
		floorOptions = createFloorOptions();
		roomOptions = createRoomOptions();
		machineOptions = createMachineOptions();
		temperatureOptions = createTemperatureOptions();
		minimumTemperatureOptions = createMinimumTemperatureOptions();	
		
		searchDescription = "";
		machineCacheMap.clear();
			
		
		scheduleTerms.clear();
		editItem = new ScheduleTerm();		
		
		clickedMachineIdMap.clear();
		clickedMachineId = 0;
		clickedMachineOptions.clear();
		
		deleteScheduleId = 0;
		deleteScheduleIdMap.clear();
		
	}

	public void search(){		
		
		// search by machine
		if (selectedMachineId > 0) {
			try {
				
				Room room = maintainService.getRoomById(selectedRoomId);				
				StringBuilder sbDesc = new StringBuilder();				
				sbDesc.append(room.getFloor().getBuilding().getBuildingName());
				sbDesc.append(", ");
				sbDesc.append(room.getFloor().getFloorName());
				sbDesc.append(", ");
				sbDesc.append(room.getRoomName());								
				searchDescription = sbDesc.toString();
				
				Machine machine = maintainService.getMachineById(selectedMachineId);
				StringBuilder sb = new StringBuilder();				
				sb.append(machine.getMachineName());
				SelectItem selectItem = new SelectItem(machine.getMachineId(), sb.toString());
				
				machineCacheMap.put(machine.getMachineId(), machine);				
				clickedMachineOptions.add(selectItem);
				
				clickedMachineIdMap.put(machine.getMachineId(), true);
				
				status = STATUS_SEARCH;
				
			} catch (Exception e) {
				logger.error(e.getLocalizedMessage());
			}
			return;
		}

		// search by room
		if (selectedRoomId > 0) {
			try {								
				Room room = maintainService.getRoomById(selectedRoomId);
				
				StringBuilder sbDesc = new StringBuilder();				
				sbDesc.append(room.getFloor().getBuilding().getBuildingName());
				sbDesc.append(", ");
				sbDesc.append(room.getFloor().getFloorName());
				sbDesc.append(", ");
				sbDesc.append(room.getRoomName());								
				searchDescription = sbDesc.toString();
				
				List<Machine> machines = maintainService.getMachines(null, null, room, null, Status.ACTIVE);
				Iterator<Machine> iterator = machines.iterator();
				while (iterator.hasNext()) {
					Machine machine = iterator.next();
					StringBuilder sb = new StringBuilder();					
					sb.append(machine.getMachineName());

					
					SelectItem selectItem = new SelectItem(machine.getMachineId(), sb.toString());
					clickedMachineOptions.add(selectItem);
					
					machineCacheMap.put(machine.getMachineId(), machine);
					
					clickedMachineIdMap.put(machine.getMachineId(), true);
					
				}
				
				status = STATUS_SEARCH;
			} catch (Exception e) {
				logger.error(e.getLocalizedMessage());
			}
			return;
		}

		// search by floor
		if (selectedFloorId > 0) {
			try {
				Floor floor = maintainService.getFloorById(selectedFloorId);
				
				StringBuilder sbDesc = new StringBuilder();				
				sbDesc.append(floor.getBuilding().getBuildingName());
				sbDesc.append(", ");
				sbDesc.append(floor.getFloorName());											
				searchDescription = sbDesc.toString();
				
				List<Machine> machines = maintainService.getMachines(null, floor, null, null, Status.ACTIVE);
				Iterator<Machine> iterator = machines.iterator();
				while (iterator.hasNext()) {
					Machine machine = iterator.next();
					StringBuilder sb = new StringBuilder();					
					sb.append(machine.getRoom().getRoomName());
					sb.append(", ");
					sb.append(machine.getMachineName());

					SelectItem selectItem = new SelectItem(machine.getMachineId(), sb.toString());
					clickedMachineOptions.add(selectItem);
					
					machineCacheMap.put(machine.getMachineId(), machine);
					
					
					clickedMachineIdMap.put(machine.getMachineId(), true);
					
				}
				
				status = STATUS_SEARCH;
			} catch (Exception e) {
				logger.error(e.getLocalizedMessage());
			}
			return;
		}

		// search by building
		if (selectedBuildingId > 0) {
			try {
				Building building = maintainService.getBuildingById(selectedBuildingId);
				
				StringBuilder sbDesc = new StringBuilder();				
				sbDesc.append(building.getBuildingName());														
				searchDescription = sbDesc.toString();
				
				List<Machine> machines = maintainService.getMachines(building, null, null, null, Status.ACTIVE);
				Iterator<Machine> iterator = machines.iterator();
				while (iterator.hasNext()) {
					Machine machine = iterator.next();
					StringBuilder sb = new StringBuilder();					
					sb.append(machine.getRoom().getFloor().getFloorName());
					sb.append(", ");
					sb.append(machine.getRoom().getRoomName());
					sb.append(", ");
					sb.append(machine.getMachineName());

					SelectItem selectItem = new SelectItem(machine.getMachineId(), sb.toString());
					clickedMachineOptions.add(selectItem);
					
					machineCacheMap.put(machine.getMachineId(), machine);					
					
					clickedMachineIdMap.put(machine.getMachineId(), true);
				}
				
				status = STATUS_SEARCH;
			} catch (Exception e) {
				logger.error(e.getLocalizedMessage());
			}
			return;
		}
		
		//no search search criteria
		String message = MessageBundle.getInstance().getMessage("error_search_criteria_fail", FacesContext.getCurrentInstance().getViewRoot().getLocale());
		FacesMessage facesMessage = new FacesMessage(message);
		FacesContext.getCurrentInstance().addMessage(null, facesMessage);
	}
	
	public void selectAll(){
		Set<Long> keySet = clickedMachineIdMap.keySet();
		Iterator<Long> iter = keySet.iterator();
		while(iter.hasNext()){
			long key = iter.next();
			clickedMachineIdMap.put(key, true);
		}
	}
	
	public void clearAll(){
		Set<Long> keySet = clickedMachineIdMap.keySet();
		Iterator<Long> iter = keySet.iterator();
		while(iter.hasNext()){
			long key = iter.next();
			clickedMachineIdMap.put(key, false);
		}
		
	}
	
	public void updateMachineIdList(AjaxBehaviorEvent event){
		UIInput input = (UIInput) event.getComponent();
		Object contentValue = input.getValue();
		if(contentValue instanceof Boolean){
			boolean b = (Boolean) contentValue;
			clickedMachineIdMap.put(clickedMachineId, !b);
		}		
	}
	
	public void selectAllSchedule(){
		Set<Long> keySet = deleteScheduleIdMap.keySet();
		Iterator<Long> iter = keySet.iterator();
		while(iter.hasNext()){
			long key = iter.next();
			deleteScheduleIdMap.put(key, true);
		}
	}
	
	public void clearAllSchedule(){
		Set<Long> keySet = deleteScheduleIdMap.keySet();
		Iterator<Long> iter = keySet.iterator();
		while(iter.hasNext()){
			long key = iter.next();
			deleteScheduleIdMap.put(key, false);
		}
	}
	
	public void updateDeleteScheduleIdList(AjaxBehaviorEvent event){
		UIInput input = (UIInput) event.getComponent();
		Object contentValue = input.getValue();
		if(contentValue instanceof Boolean){
			boolean b = (Boolean) contentValue;
			deleteScheduleIdMap.put(deleteScheduleId, !b);
		}		
	}
	
	
	public void selectDetail(){
		scheduleTerms.clear();
		deleteScheduleIdMap.clear();
		
		int count = 0;
		
		StringBuilder sbDesc = new StringBuilder();
		Iterator<Long> iterator = clickedMachineIdMap.keySet().iterator();
		while(iterator.hasNext()){
						
			try{
				long machineId = iterator.next();
				boolean clicked = clickedMachineIdMap.get(machineId);
				if(clicked){
					Machine machine = machineCacheMap.get(machineId);
					sbDesc.append(machine.getMachineName());
					sbDesc.append(" / ");
					
					List<ScheduleTerm> tmpList = scheduleControlService.getScheduleTerm(machine);
					for(int i=0; i<tmpList.size(); i++){
						ScheduleTerm scheduleTerm = tmpList.get(i);
						deleteScheduleIdMap.put(scheduleTerm.getId(), false);
					}													
					scheduleTerms.addAll(tmpList);
					
					count++;
				}
			}catch(Exception ex){}
		}
		
		//no search search criteria
		if(count == 0){
			String message = MessageBundle.getInstance().getMessage("error_search_criteria_fail", FacesContext.getCurrentInstance().getViewRoot().getLocale());
			FacesMessage facesMessage = new FacesMessage(message);
			FacesContext.getCurrentInstance().addMessage(null, facesMessage);
			return;
		}
				
		
		searchDescription = sbDesc.toString();
		status = STATUS_SELECT;
	}
	
	public void selectItem(){		
		try {
			editItem = scheduleControlService.getScheduleTermById(selectedScheduleTermId);			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
			
	}

	public void update(){
		try {
			UserDetails userDetails=  (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
			editItem.setUpdateUser(userDetails.getUsername());
			editItem.setUpdateDate(new Date());
			scheduleControlService.updateSchedule(editItem);
			selectDetail();
		} catch (Exception e) {
			String message = MessageBundle.getInstance().getMessage("error_update_fail", FacesContext.getCurrentInstance().getViewRoot().getLocale());
			FacesMessage facesMessage = new FacesMessage(message);
			FacesContext.getCurrentInstance().addMessage(null, facesMessage);
		}
		
	}
	
	public void remove(){
		try {
			scheduleControlService.deleteSchedule(selectedScheduleTermId);
			selectDetail();
		} catch (Exception e) {
			String message = MessageBundle.getInstance().getMessage("error_remove_fail", FacesContext.getCurrentInstance().getViewRoot().getLocale());
			FacesMessage facesMessage = new FacesMessage(message);
			FacesContext.getCurrentInstance().addMessage(null, facesMessage);
		}
	}
	
	public void newItem(){
		editItem = new ScheduleTerm();
	}
	
	public void create() {

		Date date = new Date();
		UserDetails userDetails=  (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		
		Iterator<Long> iterator = clickedMachineIdMap.keySet().iterator();
		
		while (iterator.hasNext()) {
			
			try {
				long machineId = iterator.next();
				boolean clicked = clickedMachineIdMap.get(machineId);

				if(clicked){
					Machine machine = maintainService.getMachineById(machineId);
					
					if(machine != null){
					
						ScheduleTerm scheduleTerm = new ScheduleTerm();
						scheduleTerm.setCreateDate(date);
						scheduleTerm.setCreateUser(userDetails.getUsername());
						scheduleTerm.setUpdateDate(date);
						scheduleTerm.setUpdateUser(userDetails.getUsername());
						
						scheduleTerm.setMachine(machine);
						
						scheduleTerm.setActive(editItem.isActive());
						scheduleTerm.setControlMode(editItem.getControlMode());
						scheduleTerm.setCmd(editItem.getCmd());
						scheduleTerm.setFanSpeed(editItem.getFanSpeed());
						scheduleTerm.setMinimumTemperature(editItem.getMinimumTemperature());
						scheduleTerm.setNid(editItem.getNid());
						scheduleTerm.setScheduleHour(editItem.getScheduleHour());
						scheduleTerm.setScheduleMin(editItem.getScheduleMin());
						scheduleTerm.setStart(editItem.isStart());
						scheduleTerm.setTemperature(editItem.getTemperature());
						scheduleTerm.setUnmonitored(editItem.getUnmonitored());
						scheduleTerm.setWindValue(editItem.getWindValue());
						scheduleTerm.setKeyLock(editItem.getKeyLock());
						scheduleTerm.setErrorMessage(editItem.getErrorMessage());
						
						
						scheduleTerm.setExecMon(editItem.isExecMon());
						scheduleTerm.setExecTue(editItem.isExecTue());
						scheduleTerm.setExecWed(editItem.isExecWed());
						scheduleTerm.setExecThu(editItem.isExecThu());
						scheduleTerm.setExecFri(editItem.isExecFri());
						scheduleTerm.setExecSat(editItem.isExecSat());
						scheduleTerm.setExecSun(editItem.isExecSun());
						
						scheduleControlService.createSchedule(scheduleTerm);
					}
				}

			} catch (Exception ex) {
				String message = MessageBundle.getInstance().getMessage("error_create_fail", FacesContext.getCurrentInstance().getViewRoot().getLocale());
				FacesMessage facesMessage = new FacesMessage(message);
				FacesContext.getCurrentInstance().addMessage(null, facesMessage);
				return;
			}
		}

		editItem = new ScheduleTerm();
		selectDetail();

	}
	
	public void deleteAllSchedule(){
		Iterator<Long> iterator = deleteScheduleIdMap.keySet().iterator();
		while(iterator.hasNext()){			
			try {
				long id = iterator.next();
				boolean clicked = deleteScheduleIdMap.get(id);
				if(clicked){
					scheduleControlService.deleteSchedule(id);
				}
				
			}catch (Exception e) {
				String message = MessageBundle.getInstance().getMessage("error_remove_fail", FacesContext.getCurrentInstance().getViewRoot().getLocale());
				FacesMessage facesMessage = new FacesMessage(message);
				FacesContext.getCurrentInstance().addMessage(null, facesMessage);
			}
		}
		selectDetail();
	}

	public void buildingValueChanged(ValueChangeEvent event) {
		if (null != event.getNewValue()) {
			selectedFloorId = 0;
			selectedRoomId = 0;
			selectedMachineId = 0;
			selectedBuildingId = (Long) event.getNewValue();
			floorOptions = createFloorOptions();
			roomOptions = createRoomOptions();
			machineOptions = createMachineOptions();
		}
	}

	public void floorValueChanged(ValueChangeEvent event) {
		if (null != event.getNewValue()) {
			selectedRoomId = 0;
			selectedMachineId = 0;
			selectedFloorId = (Long) event.getNewValue();
			roomOptions = createRoomOptions();
			machineOptions = createMachineOptions();
		}
	}

	public void roomValueChanged(ValueChangeEvent event) {
		if (null != event.getNewValue()) {
			selectedMachineId = 0;
			selectedRoomId = (Long) event.getNewValue();
			machineOptions = createMachineOptions();
		}
	}

	private List<SelectItem> createBuildingOptions() {
		List<SelectItem> results = new ArrayList<SelectItem>();
		results.add(new SelectItem(0,"------"));
		try {
			List<Building> buildings = maintainService.getAllBuildings(Status.ACTIVE);
			for (Building building : buildings) {
				SelectItem item = new SelectItem(building.getBuildingId(), building.getBuildingName());
				results.add(item);
			}
		} catch (Exception e) {
			logger.error(e.getMessage());
		}

		return results;
	}

	private List<SelectItem> createFloorOptions() {
		List<SelectItem> results = new ArrayList<SelectItem>();
		results.add(new SelectItem(0,"------"));
		try {
			if (selectedBuildingId > 0) {
				Building selectedBuilding = maintainService.getBuildingById(selectedBuildingId);
				List<Floor> floors = maintainService.getFloors(selectedBuilding, null, Status.ACTIVE);
				for (Floor floor : floors) {
					SelectItem item = new SelectItem(floor.getFloorId(), floor.getFloorName());
					results.add(item);
				}
			}
		} catch (Exception e) {
			logger.error(e.getMessage());
		}
		return results;
	}

	private List<SelectItem> createRoomOptions() {
		List<SelectItem> results = new ArrayList<SelectItem>();
		results.add(new SelectItem(0,"------"));
		try {
			if (selectedFloorId > 0) {
				Floor selectedFloor = maintainService.getFloorById(selectedFloorId);
				List<Room> rooms = maintainService.getRooms(null, selectedFloor, null, Status.ACTIVE);
				for (Room room : rooms) {
					SelectItem item = new SelectItem(room.getRoomId(), room.getRoomName());
					results.add(item);
				}
			}
		} catch (Exception e) {
			logger.error(e.getLocalizedMessage());
		}
		return results;
	}

	private List<SelectItem> createMachineOptions() {
		List<SelectItem> results = new ArrayList<SelectItem>();
		results.add(new SelectItem(0,"------"));
		try {
			if (selectedRoomId > 0) {
				Room selectedRoom = maintainService.getRoomById(selectedRoomId);
				List<Machine> machines = maintainService.getMachines(null, null, selectedRoom, null, Status.ACTIVE);
				for (Machine machine : machines) {
					SelectItem item = new SelectItem(machine.getMachineId(), machine.getMachineName());
					results.add(item);
				}
			}
		} catch (Exception e) {
			logger.error(e.getLocalizedMessage());
		}
		return results;
	}
	
	private List<SelectItem> createHourOptions(){
		List<SelectItem> results = new ArrayList<SelectItem>();
		results.add(new SelectItem("00", "00"));
		results.add(new SelectItem("01", "01"));
		results.add(new SelectItem("02", "02"));
		results.add(new SelectItem("03", "03"));
		results.add(new SelectItem("04", "04"));
		results.add(new SelectItem("05", "05"));
		results.add(new SelectItem("06", "06"));
		results.add(new SelectItem("07", "07"));
		results.add(new SelectItem("08", "08"));
		results.add(new SelectItem("09", "09"));
		results.add(new SelectItem("10", "10"));
		results.add(new SelectItem("11", "11"));
		results.add(new SelectItem("12", "12"));
		results.add(new SelectItem("13", "13"));
		results.add(new SelectItem("14", "14"));
		results.add(new SelectItem("15", "15"));
		results.add(new SelectItem("16", "16"));
		results.add(new SelectItem("17", "17"));
		results.add(new SelectItem("18", "18"));
		results.add(new SelectItem("19", "19"));
		results.add(new SelectItem("20", "20"));
		results.add(new SelectItem("21", "21"));
		results.add(new SelectItem("22", "22"));
		results.add(new SelectItem("23", "23"));
		return results;	
	}
	
	private List<SelectItem> createMinuteOptions(){
		List<SelectItem> results = new ArrayList<SelectItem>();
		results.add(new SelectItem("00", "00"));
		results.add(new SelectItem("05", "05"));
		results.add(new SelectItem("10", "10"));
		results.add(new SelectItem("15", "15"));
		results.add(new SelectItem("20", "20"));
		results.add(new SelectItem("25", "25"));
		results.add(new SelectItem("30", "30"));
		results.add(new SelectItem("35", "35"));
		results.add(new SelectItem("40", "40"));
		results.add(new SelectItem("45", "45"));
		results.add(new SelectItem("50", "50"));
		results.add(new SelectItem("55", "55"));			
		return results;
	}
	
	private List<SelectItem> createTemperatureOptions(){
		List<SelectItem> results = new ArrayList<SelectItem>();
		for(int i=16; i<=30; i++){
			results.add(new SelectItem(i,String.valueOf(i)));
		}
		return results;
	}
	
	private List<SelectItem> createMinimumTemperatureOptions(){
		List<SelectItem> results = new ArrayList<SelectItem>();
		//results.add(new SelectItem(0,String.valueOf(0)));
		for(int i=16; i<=30; i++){
			results.add(new SelectItem(i,String.valueOf(i)));
		}
		
		return results;
	}

	public MaintainService getMaintainService() {
		return maintainService;
	}

	public void setMaintainService(MaintainService maintainService) {
		this.maintainService = maintainService;
	}

	public List<SelectItem> getBuildingOptions() {
		return buildingOptions;
	}

	public void setBuildingOptions(List<SelectItem> buildingOptions) {
		this.buildingOptions = buildingOptions;
	}

	public List<SelectItem> getFloorOptions() {
		return floorOptions;
	}

	public void setFloorOptions(List<SelectItem> floorOptions) {
		this.floorOptions = floorOptions;
	}

	public List<SelectItem> getRoomOptions() {
		return roomOptions;
	}

	public void setRoomOptions(List<SelectItem> roomOptions) {
		this.roomOptions = roomOptions;
	}

	public List<SelectItem> getMachineOptions() {
		return machineOptions;
	}

	public void setMachineOptions(List<SelectItem> machineOptions) {
		this.machineOptions = machineOptions;
	}

	public long getSelectedBuildingId() {
		return selectedBuildingId;
	}

	public void setSelectedBuildingId(long selectedBuildingId) {
		this.selectedBuildingId = selectedBuildingId;
	}

	public long getSelectedFloorId() {
		return selectedFloorId;
	}

	public void setSelectedFloorId(long selectedFloorId) {
		this.selectedFloorId = selectedFloorId;
	}

	public long getSelectedRoomId() {
		return selectedRoomId;
	}

	public void setSelectedRoomId(long selectedRoomId) {
		this.selectedRoomId = selectedRoomId;
	}

	public long getSelectedMachineId() {
		return selectedMachineId;
	}

	public void setSelectedMachineId(long selectedMachineId) {
		this.selectedMachineId = selectedMachineId;
	}

	public ScheduleControlService getScheduleControlService() {
		return scheduleControlService;
	}

	public void setScheduleControlService(ScheduleControlService scheduleControlService) {
		this.scheduleControlService = scheduleControlService;
	}	

	public List<SelectItem> getHourOptions() {
		return hourOptions;
	}

	public void setHourOptions(List<SelectItem> hourOptions) {
		this.hourOptions = hourOptions;
	}

	public List<SelectItem> getMinuteOptions() {
		return minuteOptions;
	}

	public void setMinuteOptions(List<SelectItem> minuteOptions) {
		this.minuteOptions = minuteOptions;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public List<SelectItem> getMinimumTemperatureOptions() {
		return minimumTemperatureOptions;
	}

	public void setMinimumTemperatureOptions(List<SelectItem> minimumTemperatureOptions) {
		this.minimumTemperatureOptions = minimumTemperatureOptions;
	}

	public List<SelectItem> getTemperatureOptions() {
		return temperatureOptions;
	}

	public void setTemperatureOptions(List<SelectItem> temperatureOptions) {
		this.temperatureOptions = temperatureOptions;
	}

	public long getSelectedScheduleTermId() {
		return selectedScheduleTermId;
	}

	public void setSelectedScheduleTermId(long selectedScheduleTermId) {
		this.selectedScheduleTermId = selectedScheduleTermId;
	}

	public String getSearchDescription() {
		return searchDescription;
	}

	public void setSearchDescription(String searchDescription) {
		this.searchDescription = searchDescription;
	}

	public List<SelectItem> getClickedMachineOptions() {
		return clickedMachineOptions;
	}

	public void setClickedMachineOptions(List<SelectItem> clickedMachineOptions) {
		this.clickedMachineOptions = clickedMachineOptions;
	}	

	public Map<Long, Machine> getMachineCacheMap() {
		return machineCacheMap;
	}

	public void setMachineCacheMap(Map<Long, Machine> machineCacheMap) {
		this.machineCacheMap = machineCacheMap;
	}

	public List<ScheduleTerm> getScheduleTerms() {
		return scheduleTerms;
	}

	public void setScheduleTerms(List<ScheduleTerm> scheduleTerms) {
		this.scheduleTerms = scheduleTerms;
	}


	public ScheduleTerm getEditItem() {
		return editItem;
	}

	public void setEditItem(ScheduleTerm editItem) {
		this.editItem = editItem;
	}
	

	public Map<Long, Boolean> getClickedMachineIdMap() {
		return clickedMachineIdMap;
	}

	public void setClickedMachineIdMap(Map<Long, Boolean> clickedMachineIdMap) {
		this.clickedMachineIdMap = clickedMachineIdMap;
	}

	public long getClickedMachineId() {
		return clickedMachineId;
	}

	public void setClickedMachineId(long clickedMachineId) {
		this.clickedMachineId = clickedMachineId;
	}

	public long getDeleteScheduleId() {
		return deleteScheduleId;
	}

	public void setDeleteScheduleId(long deleteScheduleId) {
		this.deleteScheduleId = deleteScheduleId;
	}

	public Map<Long, Boolean> getDeleteScheduleIdMap() {
		return deleteScheduleIdMap;
	}

	public void setDeleteScheduleIdMap(Map<Long, Boolean> deleteScheduleIdMap) {
		this.deleteScheduleIdMap = deleteScheduleIdMap;
	}

}
